package javacore.abstraction;

public class InstanceofDemo {

	public static void main(String[] args) {
		Parent obj1 = new Parent();
        Parent obj2 = new Child();

        System.out.println(obj1 instanceof Parent); // true
        System.out.println(obj1 instanceof Child); // false
        System.out.println(obj1 instanceof MyInterface); // false
        System.out.println(obj2 instanceof Parent); // true
        System.out.println(obj2 instanceof Child); // true
        System.out.println(obj2 instanceof MyInterface); // true
        
        System.out.println("foo".getClass());
        System.out.println(obj1.getClass());
        System.out.println(obj2.getClass());

	}

}

class Parent {}
class Child extends Parent implements MyInterface {}
interface MyInterface {}
